<template>
  <!-- 班团组织详情 -->
  <div class="app-container">
    <el-card class="box-card">
      <el-descriptions :column="2" title="" style="font-size: 15px">
        <el-descriptions-item label="组织名称">{{ orgForm.orgName }}</el-descriptions-item>
        <el-descriptions-item label="所属组织">{{ orgForm.unitName }}</el-descriptions-item>
        <el-descriptions-item label="班级">{{ orgForm.classNo }}</el-descriptions-item>
        <el-descriptions-item label="年级">{{ orgForm.grade }}</el-descriptions-item>
        <el-descriptions-item label="辅导员">{{ orgForm.teacherName }}</el-descriptions-item>
        <el-descriptions-item label="学生管理员">{{ orgForm.studentName }}</el-descriptions-item>
      </el-descriptions>
      <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
        <el-tab-pane label="任命信息" name="first"> </el-tab-pane>
        <el-tab-pane label="团小组" name="second"></el-tab-pane>
      </el-tabs>
      <el-form
        :model="queryParams"
        ref="queryForm"
        size="small"
        :inline="true"
        v-show="showSearch"
        label-width="50px"
      >
        <el-form-item label="学期" prop="schoolYear">
          <el-select
            v-model="queryParams.schoolYear"
            placeholder="请选择"
            style="width: 240px"
          >
            <el-option
              v-for="option in schoolYearList"
              :key="option.schoolYearId"
              :label="option.schoolYearId"
              :value="option.schoolYearId"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="学生">
          <el-input
            placeholder="请输入"
            clearable
            v-model="queryParams.stuIdOrStuName"
            class="input-with-select"
          >
          </el-input>
        </el-form-item>

        <el-form-item>
          <!-- <el-button type="primary" size="mini" @click="getList(orgForm, '-1')">查询</el-button> -->
          <el-button type="primary" size="mini" @click="getList(orgForm, '-1')">搜索全部</el-button>
          <el-button type="primary" size="mini" @click="getList(orgForm, '1')">有职务</el-button>
          <el-button type="primary" size="mini" @click="getList(orgForm, '0')">无职务</el-button>
          <el-button
            type="primary"
            size="mini"
            v-if="isCanRead"
            v-hasPermi="['organ:classOrgan:add']"
            @click="handleAdd(1)"
            >添加任命信息</el-button
          >
          <el-button
            type="primary"
            size="mini"
            v-if="isCanRead"
            v-hasPermi="['organ:classOrgan:batchAdd']"
            @click="handleImport"
            >批量导入任命</el-button
          >
          <el-button
            style="padding-left: 10px; padding-right: 10px; margin-top: 10px"
            size="mini"
            type="danger"
            @click="handleBatchDelete()"
            v-hasPermi="['organ:classOrgan:batchDeleteStudent']"
            >批量删除</el-button
          >
          <!-- <el-button
            type="primary"
            size="mini"
            v-if="isCanRead"
            v-hasPermi="['organ:classOrgan:batchAdd']"
            @click="examineOpenF(1)"
            >状态审核</el-button
          > -->
          <!-- <el-button
            type="primary"
            size="mini"
            v-if="isCanRead"
            v-hasPermi="['organ:classOrgan:batchAdd']"
            @click="examineOpenF(2)"
            >考核审核</el-button
          > -->
          <el-button
          v-if="isCanRead"
          type="warning"
          plain
          class="tag-read"
          icon="el-icon-document-copy"
          size="mini"
          :data-clipboard-text="'https://erke.hdu.edu.cn/weixin/#/pages/member/orgin/checkOrgan?id=' + queryParams.orgId + '&type=1&schoolYear=' + queryParams.schoolYear"
            @click="copy(1)"
            >职位审核</el-button>
            <!-- @click="examineOpenF(1)" -->
          <el-button
          v-if="isCanRead"
          type="warning"
          plain
          class="tag-read"
          icon="el-icon-document-copy"
          size="mini"
          :data-clipboard-text="'https://erke.hdu.edu.cn/weixin/#/pages/member/orgin/checkOrgan?id=' + queryParams.orgId + '&type=2&schoolYear=' + queryParams.schoolYear"
            @click="copy(2)"
            >考核审核</el-button>
            <el-button
            v-if="isCanRead"
            type="primary"
            size="mini"
            v-hasPermi="['organ:classOrgan:exports']"
            @click="handleExport"
            >导出</el-button
          >
            <el-button
            v-if="isCanRead"
            type="primary"
            size="mini"
            v-hasPermi="['organ:classOrgan:lead']"
            @click="handleImportStu"
            >批量导入考核</el-button
          >
            <!-- @click="examineOpenF(2)" -->
        </el-form-item>
      </el-form>
      <el-table
        border
        v-loading="loading"
        :data="memberList"
        @selection-change="handleSelectionChange"
      >
        <!-- <el-table-column label="序号" align="center" prop="orgMemberId" /> -->
        <el-table-column type="selection" align="center" width="55"> </el-table-column>
        <el-table-column label="学生" align="center">
          <template slot-scope="scope">
            {{ scope.row.studentName }}<br />{{ scope.row.studentId }}
          </template>
        </el-table-column>
        <el-table-column label="性别" align="center" prop="sex" />
        <el-table-column label="系部" align="center" prop="unitName" />
        <el-table-column label="职位名称" align="center" prop="positionName" />
        <el-table-column prop="status" label="状态" width="150" align="center">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.orgMemberStatus" :value="scope.row.status" />
            <!-- <span>{{ parseTime(scope.row.auditTime, '{y}-{m}-{d}') }}</span> -->
          </template>
        </el-table-column>

        <el-table-column label="创建时间" align="center" prop="createTime" width="180">
          <template slot-scope="scope" v-if="isCanRead || name == scope.row.studentId">
            <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="markStatus" label="考核状态" width="150" align="center">
          <template slot-scope="scope" v-if="isCanRead || name == scope.row.studentId">
            <dict-tag :options="dict.type.markStatus" :value="scope.row.markStatus" />
            <el-button
              style="margin: 10px"
              type="primary"
              size="mini"
              v-hasPermi="['organ:classOrgan:checkAduit']"
              @click="markDetail(scope.row)"
              >查看考核</el-button
            >
          </template>
        </el-table-column>
        <el-table-column
          label="操作"
          width="200"
          align="center"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope" v-if="isCanRead || name == scope.row.studentId">
            <el-button
              size="mini"
              type="primary"
              @click="seeHistory(scope.row)"
              style="padding-left: 10px; padding-right: 10px"
              >查看</el-button
            >
            <el-button
              style="padding-left: 10px; padding-right: 10px; margin-top: 10px"
              size="mini"
              type="danger"
              v-if="isCanRead"
              @click="handleAdd(scope.row)"
              v-hasPermi="['organ:classOrgan:add']"
              >添加任命</el-button
            >
            <el-button
              size="mini"
              type="primary"
              v-if="name == scope.row.studentId"
              @click="writeMarkHandle(scope.row)"
              v-hasPermi="['organ:classOrgan:summary']"
              style="padding-left: 10px; padding-right: 10px"
              >填写工作总结</el-button
            >
            <el-button
              style="padding-left: 10px; padding-right: 10px; margin-top: 10px"
              size="mini"
              type="danger"
              @click="handleDelete(scope.row)"
              v-hasPermi="['organ:classOrgan:deleteStudent']"
              >取消任命</el-button
            >
          </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />

      <!-- 添加或修改成员任命信息对话框 -->
      <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
        <el-form ref="form" :model="form" :rules="rules" label-width="100px">
          <el-form-item label="学期" prop="schoolYear">
            <span>{{ form.schoolYear }}</span>
            <!-- <el-select
              v-model="form.schoolYear"
              placeholder="请选择"
              clearable
              style="width: 240px"
            >
              <el-option
                v-for="(dict, index) in schoolYearList"
                :key="index"
                :label="dict.name"
                :value="dict.name"
              />
            </el-select> -->
          </el-form-item>
          <el-form-item v-if="!isStudentId" label="姓名" prop="studentId">
            <el-select
              v-model="form.studentId"
              filterable
              remote
              reserve-keyword
              placeholder="请输入关键词"
              :remote-method="remoteMethod"
              :loading="searchLoading"
            >
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="职位名称" prop="positionName">
            <el-select v-model="form.positionName" placeholder="请选择" style="width: 240px">
              <el-option
                v-for="dict in dict.type.position_1"
                :key="dict.label"
                :label="dict.label"
                :value="dict.label"
              ></el-option>
              <!-- <el-select
                  v-model="form.positionName"
                  placeholder="请选择"
                  clearable
                  
                >
                  <el-option
                    v-for="(dict,index) in positionIdList"
                    :key="index"
                    :label="dict.name"
                    :value="dict.name"
                  /> -->
            </el-select>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </el-dialog>

      <!--查看考核信息对话框 -->
      <el-dialog title="查看工作考核" :visible.sync="markOpen" width="800px" append-to-body>
        <el-form ref="markFrom" :model="markFrom" :rules="rules" label-width="100px">
          <el-form-item label="组织名称" prop="orgName">
            <span>{{ markFrom.orgName }}</span>
          </el-form-item>
          <el-form-item label="学期" prop="schoolYear">
            <span>{{ queryParams.schoolYear }}</span>
          </el-form-item>
          <el-form-item label="姓名" prop="studentName">
            <span>{{ markFrom.studentName }}</span>
          </el-form-item>
          <el-form-item label="所属系部" prop="unitName">
            <span>{{ markFrom.unitName }}</span>
          </el-form-item>
          <el-form-item label="职位" prop="positionName">
            <span>{{ markFrom.positionName }}</span>
          </el-form-item>
          <el-form-item label="工作总结" prop="summary" v-if="writeMark">
            <el-input type="textarea" v-model="markFrom.summary"></el-input>
          </el-form-item>
          <el-form-item label="工作总结" prop="summary" v-if="!writeMark">
            <span>{{ markFrom.summary }}</span>
          </el-form-item>
          <el-form-item label="考核结果" prop="mark" v-if="!writeMark">
            <span>{{ markFrom.mark }}</span>
          </el-form-item>
        </el-form>

        <!-- <el-descriptions :column="1" title=""  style="font-size: 15px;">
              <el-descriptions-item  label="组织名称">{{markFrom.orgName}}</el-descriptions-item>
              <el-descriptions-item label="学期">{{queryParams.schoolYear}}</el-descriptions-item>
              <el-descriptions-item label="姓名">{{markFrom.studentName}}</el-descriptions-item>
              <el-descriptions-item label="所属系部">{{markFrom.unitName}}</el-descriptions-item>
              <el-descriptions-item label="职位">{{markFrom.positionName}}</el-descriptions-item>
              <el-descriptions-item label="工作总结">{{markFrom.studentName}}</el-descriptions-item>
              <el-descriptions-item label="考核结果">{{markFrom.mark}}</el-descriptions-item>
          </el-descriptions> -->
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="summary" v-if="writeMark">确 定</el-button>
          <el-button @click="markCancel">取 消</el-button>
        </div>
      </el-dialog>

      <!-- 查看历史任职 -->
      <el-dialog :title="title" :visible.sync="historyOpen" width="600px" append-to-body>
        <el-table
          border
          v-loading="loading"
          :data="historyList"
          @selection-change="handleSelectionChange"
        >
          <el-table-column label="学期" align="center" prop="year" />
          <el-table-column label="职位名称" align="center" prop="name" />
        </el-table>
      </el-dialog>

      <!-- 用户导入对话框 -->
      <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
        <el-upload
          ref="upload"
          :limit="1"
          accept=".xlsx, .xls"
          :headers="upload.headers"
          :action="
            upload.url
          "
          :disabled="upload.isUploading"
          :on-progress="handleFileUploadProgress"
          :on-success="handleFileSuccess"
          :auto-upload="false"
          drag
        >
          <i class="el-icon-upload"></i>
          <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
          <div class="el-upload__tip text-center" slot="tip">
            <div class="el-upload__tip" slot="tip">
              <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
            </div>
            <span>仅允许导入xls、xlsx格式文件。</span>
            <el-link
              type="primary"
              :underline="false"
              style="font-size: 12px; vertical-align: baseline"
              @click="importTemplate"
              >下载模板</el-link
            >
          </div>
        </el-upload>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitFileForm">确 定</el-button>
          <el-button @click="upload.open = false">取 消</el-button>
        </div>
      </el-dialog>
      <!-- 审核对话框 -->
      <el-dialog :title="title" :visible.sync="examineOpen" width="500px" append-to-body>
        <el-form ref="form" :model="form" :rules="rules" label-width="80px">
          <!-- <el-form-item label="审核意见" prop="examineComments1">
          <el-input v-model="examineComments1" placeholder="请输入审核意见" />
        </el-form-item> -->
          <!-- <el-button type="primary" @click="submitFormE('1')">审核拒绝</el-button>
        <el-button type="primary" @click="submitFormE('0')">审核通过</el-button> -->
          <el-radio-group v-model="examineVal" size="small">
            <el-radio label="1" border>审核拒绝</el-radio>
            <el-radio label="2" border>审核通过</el-radio>
          </el-radio-group>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitFormE">确 定</el-button>
        </div>
      </el-dialog>
    </el-card>
  </div>
</template>

<script>
import { mapGetters } from 'vuex';
import { getToken } from '@/utils/auth';
import { GetYearList } from '@/api/organ/organ';
import {
  listMember,
  getMember,
  delMember,
  batchDelMember,
  addMember,
  updateMember,
  summary,
} from '@/api/organ/classOrganMember';
import {
  listOrg,
  getOrg,
  delOrg,
  addOrg,
  updateOrg,
  getstudentmanager,
  setstudentmanager,
} from '@/api/organ/classOrgan';
import Clipboard from 'clipboard';
export default {
  name: 'Member',
  dicts: ['sys_show_hide', 'orgMemberStatus', 'markStatus', 'position_1'],
  computed: {
    ...mapGetters(['roles', 'name', 'userName','unitName']),
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 成员任命信息表格数据
      memberList: [],
      // 成员历史任职
      historyList: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      stuIdOrStuName: '',
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orgId: null,
        studentId: null,
        studentName: null,
        teacherId: null,
        positionId: null,
        positionLevel: null,
        auditTime: null,
        positionName: null,
        status: null,
        schoolYear: null,
        markStatus: null,
        mark: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        orgId: [{ required: true, message: '组织ID不能为空', trigger: 'blur' }],
      },
      orgForm: {},
      activeName: 'first',
      schoolYearList: [],
      positionIdList: [
        {
          name: '技术部成员',
          code: '1',
        },
      ],
      // 用户导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: '',
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: 'Bearer ' + getToken() },
        // 上传的地址
        url: '',
      },
      // 是否有任职人员
      isStudentId: false,
      markOpen: false,
      historyOpen: false,
      searchLoading: false,
      options: [],
      markFrom: {},
      writeMark: false,

      isCanRead: false,
      // 审核弹框
      examineOpen: false,
      // 审核结果
      examineVal:null,
    };
  },
  created() {
    GetYearList().then(response => {
      console.log(response, 'Years');
      this.schoolYearList = response.rows;
      for (let i = 0; i < response.total; i++) {
        if (response.rows[i].defaultValue == '1') {
          console.log(response.rows[i], 'year');
          this.queryParams.schoolYear = response.rows[i].schoolYearId;
        }
      }
    });
    const pid = this.$route.params && this.$route.params.pid;
    getOrg(pid).then(response => {
      this.orgForm = response.data;
      this.queryParams.orgId = response.data.orgId;
      this.queryParams.classNo = response.data.classNo;
      this.queryParams.unitCode = response.data.unitCode;
      this.canRead();
      this.getList(this.orgForm, '-1');
    });
  },
  methods: {
    copy(type){
      var clipboard = new Clipboard('.tag-read');
      clipboard.on('success', e => {
        console.log('复制成功');
        this.$modal.msgSuccess((type==1?'职位审核链接':'考核审核链接') + '复制成功');
        // 释放内存
        clipboard.destroy();
      });
      clipboard.on('error', e => {
        // 不支持复制
        console.log('该浏览器不支持自动复制');
        this.$modal.msgError("该浏览器不支持自动复制");
        // 释放内存
        clipboard.destroy();
      });
    },
    examineOpenF(status) {
      this.title = (status == 1 ? '状态' : '考核状态') + ' 审核';
      this.examineVal = null;
      this.examineOpen = true;
    },
    submitFormE() {
      if (this.examineVal) {
        console.log('审核结果');
      }else{
        this.$modal.msgError("请选择审核结果！");
      }
    },
    canRead() {
      var isCanRead = false;
      if (this.roles) {
        console.log(this.roles, 'roles');
        for (let i = 0; i < this.roles.length; i++) {
          if (['admin', 'common'].includes(this.roles[i])) {
            isCanRead = true;
            break;
          } else if (['teacher3'].includes(this.roles[i])) {
            if (this.unitName == this.orgForm.unitName) {
              isCanRead = true;
              break;
            }
          } else if (this.name == this.orgForm.teacherId || this.name == this.orgForm.studentId) {
            isCanRead = true;
            break;
          }
        }
      }
      console.log(isCanRead, 'isCanRead');
      this.isCanRead = isCanRead;
      return isCanRead;
    },
    /** 查询成员任命信息列表 */
    getList(item, isHavaPosition) {
      if (isHavaPosition == '0' || isHavaPosition == '1') {
        this.queryParams.isHavaPosition = isHavaPosition;
      }
      if (isHavaPosition == '-1') {
        this.queryParams.isHavaPosition = null;
      }
      this.loading = true;
      listMember(this.queryParams).then(response => {
        this.memberList = response.rows;
        //console.log(this.memberList)
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 取消按钮
    markCancel() {
      this.markOpen = false;
    },
    // 表单重置
    reset() {
      this.form = {
        orgMemberId: null,
        orgId: null,
        studentId: null,
        studentName: null,
        teacherId: null,
        createTime: null,
        createBy: null,
        positionId: null,
        positionLevel: null,
        auditTime: null,
        positionName: null,
        status: '0',
        schoolYear: null,
        markStatus: '0',
        mark: null,
      };
      this.resetForm('form');
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm');
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.orgMemberId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    // 查看历史任职
    seeHistory(row) {
      this.title = '查看 ' + row.studentName + ' 历史任命';
      this.historyList = row.positionNameList;
      console.log(this.historyList, 'history');
      this.historyOpen = true;
    },
    /** 新增按钮操作 */
    handleAdd(row) {
      this.reset();
      this.open = true;
      this.isStudentId = false;
      this.title =
        row != 1 ? '添加 ' + row.studentName + ' 任命' : '添加 ' + this.orgForm.orgName + ' 任命';
      if (row != 1) {
        this.form.studentId = row.studentId;
        this.form.orgMemberId = row.orgMemberId;
        this.isStudentId = true;
      }
      this.form.schoolYear = this.queryParams.schoolYear;
    },
    // 批量任命信息导入按钮
    handleImport() {
      this.upload.title = '批量任命信息导入';
      this.upload.open = true;
      this.upload.url = process.env.VUE_APP_BASE_API + '/committee/member/importData' + '?updateSupport=' + this.upload.updateSupport + '&orgId=' + this.orgForm.orgId
      console.log(this.upload.url);
    },
    /** 下载模板操作 */
    importTemplate() {
      if(this.upload.title == '批量任命信息导入'){
        this.download(
        '/committee/member/importTemplate2',
        {},
        `classOrgan_template_${new Date().getTime()}.xlsx`
      );
      }else if(this.upload.title == '批量考核信息导入'){
        this.download(
        'committee/member/export',
        {
          ...this.queryParams,
        },
        `member_${new Date().getTime()}.xlsx`
      );
      }
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert(
        "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
          response.msg +
          '</div>',
        '导入结果',
        { dangerouslyUseHTMLString: true }
      );
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
    /**查看考核按钮操作 */
    markDetail(row) {
      this.writeMark = false;
      this.markOpen = true;
      this.markFrom = row;
      console.log(this.markFrom);
    },
    // 批量考核导入按钮
    handleImportStu(){
      this.upload.title = '批量考核信息导入';
      this.upload.open = true
      this.upload.url = process.env.VUE_APP_BASE_API + '/committee/member/import' + '?updateSupport=' + this.upload.updateSupport + '&orgId=' + this.orgForm.orgId
      console.log(this.upload.url);
    },
    /**查看填写工作日志操作 */
    writeMarkHandle(row) {
      this.writeMark = true;
      this.markOpen = true;
      this.markFrom = row;
      console.log(this.markFrom);
    },
    summary() {
      summary(this.markFrom).then(response => {
        if (response.code == 200) {
          this.$modal.msgSuccess(response.msg);
          this.markOpen = false;
          this.getList();
        }
      });
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const orgMemberId = row.orgMemberId || this.ids;
      getMember(orgMemberId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = '修改成员任命信息';
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          this.form.orgId = this.orgForm.orgId;
          addMember(this.form).then(response => {
            if (response.code == 200) {
              this.$modal.msgSuccess('操作成功');
              this.open = false;
              this.getList();
            }
          });
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const orgMemberIds = row.orgMemberId;
      this.$modal
        .confirm('是否确认删除成员为"' + row.studentName + '"的任命？')
        .then(function () {
          return delMember(orgMemberIds);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess('删除成功');
        })
        .catch(() => {});
    },
    /** 批量删除按钮操作 */
    handleBatchDelete() {
      const orgMemberIds = this.ids;
      const schoolYear = this.queryParams.schoolYear;
      console.log(orgMemberIds, 'ids');
      if (orgMemberIds.length > 0) {
        this.$modal
          .confirm('是否确认批量删除任命？')
          .then(function () {
            return batchDelMember(schoolYear, orgMemberIds);
          })
          .then(() => {
            this.getList();
            this.$modal.msgSuccess('删除成功');
          })
          .catch(() => {});
      } else {
        this.$modal.msgError('请选择数据！');
      }
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        'committee/member/export',
        {
          ...this.queryParams,
        },
        `member_${new Date().getTime()}.xlsx`
      );
    },
    /** 切换标签卡 */
    handleClick(tab, event) {
      if (tab.index == '0') {
        this.showSearch = true;
      } else {
        this.showSearch = false;
      }
    },
    /** 查询学生管理员 */
    remoteMethod(query) {
      if (query !== '') {
        this.loading = true;
        getstudentmanager(query).then(response => {
          this.loading = false;
          this.options = response.rows.filter(item => {
            return item.label.toLowerCase().indexOf(query.toLowerCase()) > -1;
          });
        });
      } else {
        this.options = [];
      }
    },
  },
};
</script>
